//package com.xinxin.intelligenceexam.studyMenu.recyclerViewPull;
//
//import android.os.Bundle;
//import android.os.Handler;
//import android.support.v4.widget.SwipeRefreshLayout;
//import android.support.v7.app.AppCompatActivity;
//import android.support.v7.widget.DefaultItemAnimator;
//import android.support.v7.widget.LinearLayoutManager;
//import android.support.v7.widget.RecyclerView;
//import android.util.TypedValue;
//
//import com.xinxin.intelligenceexam.R;
//
//public class RecyclerViewPullActivity extends AppCompatActivity{
//
//    private SwipeRefreshLayout mSwipeRefreshWidget;
//    private RecyclerView mRecyclerView;
//    private int lastVisibleItem;
//    private Handler handler = new Handler();
//    LinearLayoutManager mLayoutManager;
//    SampleAdapter adapter;
//    @Override
//    protected void onCreate(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_recycler_view_pull);
//
//        mSwipeRefreshWidget = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_widget);
//        mRecyclerView = (RecyclerView) findViewById(android.R.id.list);
//
////        mSwipeRefreshWidget.setColorScheme(R.color.color1, R.color.color2,
////                R.color.color3, R.color.color4);
//        mSwipeRefreshWidget.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
//            @Override
//            public void onRefresh() {
//
//            }
//        });
//
//        // 这句话是为了，第一次进入页面的时候显示加载进度条
//        mSwipeRefreshWidget.setProgressViewOffset(false, 0, (int) TypedValue
//                .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24, getResources()
//                        .getDisplayMetrics()));
//
//
//        mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
//
//            @Override
//            public void onScrollStateChanged(RecyclerView recyclerView,
//                                             int newState) {
//                super.onScrollStateChanged(recyclerView, newState);
//                if (newState == RecyclerView.SCROLL_STATE_IDLE
//                        && lastVisibleItem + 1 == adapter.getItemCount()) {
//                    mSwipeRefreshWidget.setRefreshing(true);
//                    // 此处在现实项目中，请换成网络请求数据代码，sendRequest .....
//                    handler.sendEmptyMessageDelayed(0, 3000);
//                }
//            }
//
//            @Override
//            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
//                super.onScrolled(recyclerView, dx, dy);
//
//                lastVisibleItem = mLayoutManager.findLastVisibleItemPosition();
//            }
//
//        });
//
//        mRecyclerView.setHasFixedSize(true);
//        mLayoutManager = new LinearLayoutManager(this);
//        mRecyclerView.setLayoutManager(mLayoutManager);
//        mRecyclerView.setItemAnimator(new DefaultItemAnimator());
//
//        adapter = new SampleAdapter();
//        mRecyclerView.setAdapter(adapter);
//
//        // 此处在现实项目中，请换成网络请求数据代码，sendRequest .....
//        handler.sendEmptyMessageDelayed(0, 3000);
//    }
//}
//